package mlz.c_newDateClass;

import java.sql.SQLOutput;
import java.time.LocalDate;
import java.time.Period;

//Period: 时间间隔类 年月日
public class PeriodDemo07 {
    public static void main(String[] args) {
        //获取年月日时间对象
        LocalDate date1 = LocalDate.of(2099, 8, 10);
        LocalDate date2 = LocalDate.of(2099, 12, 12);

        //创建对象,封装两个日期对象
        Period period = Period.between(date1, date2);
        System.out.println(period);//P4M2D

        //获取当前对象中的所有时间信息
        System.out.println(period.getYears());//0
        System.out.println(period.getMonths());//4
        System.out.println(period.getDays());//2



    }
}









